﻿using System;
using System.Collections.Generic;
using System.Text;

namespace CYTools.Util
{
    public class CommonUtil
    {
        /// <summary>
        /// 当前系统时间
        /// </summary>
        /// <returns></returns>
        public static DateTime getDateTime()
        {
            return DateTime.Now;
        }
        /// <summary>
        /// 当前日期
        /// </summary>
        /// <returns></returns>
        public static DateTime getDate()
        {
            DateTime dt = DateTime.Now;
            String date = string.Format("{0:d}", dt);
            return Convert.ToDateTime(date);
        }
        public static DateTime getFormatDate(string str)
        {
            return Convert.ToDateTime(str);
        }
        /// <summary>
        /// 格式化当前时间
        /// </summary>
        /// <returns></returns>
        public static String getDateTime(DateTime dt, String format)
        {
            //String date = string.Format("{0:s}", dt);
            return dt.ToString(format);
        }
        /// <summary>
        /// 格式化当前时间
        /// </summary>
        /// <returns></returns>
        public static String getNowDateTime(String format)
        {
            //String date = string.Format("{0:s}", dt);
            return DateTime.Now.ToString(format);
        }
    }
}
